package com.dwxt.sport.business.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.sport.business.entity.AdolescentSportsHealth;
import com.dwxt.sport.business.entity.AdolescentSportsHealthEquipment;
import com.dwxt.sport.business.service.AdolescentSportsHealthService;
import com.dwxt.sport.business.vo.adolescentSportsHealth.InsertOrUpdateAdolescentSportsHealthEquipmentVo;
import com.dwxt.sport.business.vo.adolescentSportsHealth.InsertOrUpdateAdolescentSportsHealthVo;
import com.dwxt.sport.business.vo.adolescentSportsHealth.SelectAdolescentSportsHealthVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 青少年运动健康
 *
 * @author Kuang.JiaZhuo
 * @date 2020-07-30 10:15
 */
@RestController
@RequestMapping("/adolescentSportsHealth")
@Api(tags={"青少年运动健康"})
public class AdolescentSportsHealthController {

    @Resource
    AdolescentSportsHealthService adolescentSportsHealthService;

    @ApiOperation(value = "新增或修改青少年运动健康", notes = "新增或修改青少年运动健康", response = Integer.class)
    @PostMapping("/back/insertOrUpdateAdolescentSportsHealth")
    public BaseResult insertOrUpdateAdolescentSportsHealth(InsertOrUpdateAdolescentSportsHealthVo insertOrUpdateVo){
        int result = this.adolescentSportsHealthService.insertOrUpdateAdolescentSportsHealth(insertOrUpdateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "获取青少年运动健康列表", notes = "按条件查询青少年运动健康列表(带分页)", response = AdolescentSportsHealth.class)
    @PostMapping("/back/selectAdolescentSportsHealthByCriteria")
    public BaseResult selectAdolescentSportsHealthByCriteria(SelectAdolescentSportsHealthVo selectVo){
        PageInfo<AdolescentSportsHealth> pageInfo = this.adolescentSportsHealthService.selectAdolescentSportsHealthByCriteria(selectVo);
        return BaseResult.ok(pageInfo);
    }

    @ApiOperation(value = "删除【青少年运动健康】", notes = "根据ids批量删除【青少年运动健康】", response= Integer.class)
    @PostMapping(value = "/back/deleteAdolescentSportsHealthByIds")
    public BaseResult deleteAdolescentSportsHealthByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.adolescentSportsHealthService.deleteAdolescentSportsHealthByIds(ids);
        return BaseResult.ok(result);
    }


    /******************************************************************  关联设备  ******************************************************************************/

    @ApiOperation(value = "新增 或 更新【青少年运动健康】设备关联", notes = "新增 或 更新【青少年运动健康】设备关联", response = Integer.class)
    @PostMapping("/back/insertOrUpdateAdolescentSportsHealthEquipment")
    public BaseResult insertOrUpdateAdolescentSportsHealthEquipment(InsertOrUpdateAdolescentSportsHealthEquipmentVo insertOrUpdateVo){
        int result = this.adolescentSportsHealthService.insertOrUpdateAdolescentSportsHealthEquipment(insertOrUpdateVo);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "删除【青少年运动健康】设备关联", notes = "根据ids批量删除【青少年运动健康】设备关联", response= Integer.class)
    @PostMapping(value = "/back/deleteAdolescentSportsHealthEquipmentByIds")
    public BaseResult deleteAdolescentSportsHealthEquipmentByIds(@ApiParam(value = "要删除的id字符串,以英文逗号隔开", required = true) @RequestParam String ids){
        int result = this.adolescentSportsHealthService.deleteAdolescentSportsHealthEquipmentByIds(ids);
        return BaseResult.ok(result);
    }

    @ApiOperation(value = "查询【青少年运动健康】的设备列表", notes = "根据【青少年运动健康】的id查询关联设备的列表(带分页)", response= AdolescentSportsHealthEquipment.class)
    @PostMapping(value = "/back/selectAdolescentSportsHealthEquipmentByCriteria")
    public BaseResult selectAdolescentSportsHealthEquipmentByCriteria(@ApiParam(value = "青少年运动健康关联id", required = true) @RequestParam String id,
                                                      @ApiParam(value = "起始页", required = true) @RequestParam Integer pageNum,
                                                      @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize){
        String healthId = id;
        PageInfo<AdolescentSportsHealthEquipment> pageInfo = this.adolescentSportsHealthService.selectAdolescentSportsHealthEquipmentByCriteria(pageNum,pageSize,healthId);
        return BaseResult.ok(pageInfo);
    }


}
